<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateTableProductKey extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		//
		Schema::create('product_key', function($table){
			$table->bigIncrements('id');
			$table->bigInteger('product_id')->unsigned();
			$table->string('key', 100);
			$table->tinyInteger('is_used')->default(0);
			$table->timestamps();
			$table->softDeletes();

			$table->unique('key');
			$table->index('key');

			$table->foreign('product_id')->references('id')->on('product');
		});
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		//
	}

}
